dynamic_menu object

This method returns the current position of the menu cursor.

double get_position()

Parameters:
None.

Return value:
A double indicating the position of the menu cursor on success, or -1 on failure.

Remarks:
This method may only be used while the menu is active. Thus, it can only be used from within a callback function.

Example:
// Make a simple menu and use a callback. The callback will check the current position with a variable and play a sound if the position has changed.

#include "dynamic_menu.bgt"

sound movement;
dynamic_menu menu;
int menu_position;

void main()
{
int menu_result;
menu.allow_escape=true;
menu.wrap=false;
menu.set_callback(check_menu_events, "");
menu.add_item_tts("Start game.");
menu.add_item_tts("Test speakers.");
menu.add_item_tts("Exit.");
menu_result=menu.run("Please choose an option", true);
if(menu_result==-1)
{
alert("Error", "There was an error loading the menu.");
exit();
}
if(menu_result==0)
{
alert("Option", "Escape was pressed. Exiting.");
exit();
}
if(menu_result==1)
{
alert("Option", "Option selected was start game.");
}
if(menu_result==2)
{
alert("Option", "Option selected was test speakers.");
}
if(menu_result==3)
{
alert("Option", "Option selected was exit. Exiting.");
exit();
}
}

int check_menu_events(dynamic_menu@ game_menu, string data)
{
if(game_menu.get_position()!=menu_position)
{
movement.load("menumove.wav");
movement.play_wait();
movement.close();
menu_position=game_menu.get_position();
}
return 0;
}